/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NetMonitorPanel.java
 *
 * Created on 30-dic-2008, 17.50.53
 */

package lpr.minikazaa.GUI;

import lpr.minikazaa.minikazaaclient.SupernodeList;

/**
 *
 * @author giovine
 */
public class NetMonitorPanel extends javax.swing.JPanel {

    SupernodeList my_snlist;
    /** Creates new form NetMonitorPanel */
    public NetMonitorPanel(SupernodeList sn_list) {
        this.my_snlist = sn_list;
        initComponents();

        this.my_snlist.addObserver((SuperNodesTable)this.supernode_table);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        supernode_table = new javax.swing.JTable();
        refresh_bt = new javax.swing.JButton();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Net Monitor"));

        supernode_table = new SuperNodesTable(this.my_snlist);/*
        supernode_table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Stato", "Indirizzo peer", "Ping"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        */
        jScrollPane1.setViewportView(supernode_table);

        refresh_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lpr/minikazaa/icons/refresh_icon.png"))); // NOI18N
        refresh_bt.setText("Refresh Ping");
        refresh_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refresh_btActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(355, Short.MAX_VALUE)
                .addComponent(refresh_bt)
                .addContainerGap())
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(refresh_bt)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void refresh_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refresh_btActionPerformed
        this.my_snlist.refreshPing();
    }//GEN-LAST:event_refresh_btActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton refresh_bt;
    private javax.swing.JTable supernode_table;
    // End of variables declaration//GEN-END:variables

}
